using System;
using System.Collections.Generic;
using System.Text;
using Entities;
using DAL;

namespace BUS
{
    public class tbKhachHangBUS
    {
        public static void Insert(tbKhachHang khachhang)
        {
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            khachhangDAL.Insert(khachhang);
        }
        public static void Update(tbKhachHang khachhang)
        {
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            khachhangDAL.Update(khachhang);
        }
        public static void Delete(int iD)
        {
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            khachhangDAL.Delete(iD);
        }
        public static tbKhachHang.tbKhachHangCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            return khachhangDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbKhachHang.tbKhachHangCollection GetAll()
        {
            int total = 0;
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            return khachhangDAL.Get("where 1=1", 0, 0, tbKhachHang.tbKhachHangColumns.IDKhachHang.ToString(), "ASC", out total);
        }
        public static tbKhachHang GetByID(int iD)
        {
            int total = 0;
            tbKhachHangDAL khachhangDAL = new tbKhachHangDAL();
            tbKhachHang.tbKhachHangCollection khachhangCollection = khachhangDAL.Get("where " + tbKhachHang.tbKhachHangColumns.IDKhachHang.ToString() + "=" + iD.ToString(), 0, 0, tbKhachHang.tbKhachHangColumns.IDKhachHang.ToString(), "ASC", out total);
            if (khachhangCollection.Count > 0)
                return khachhangCollection[0];
            return null;
        }
    }
}
